package com.itheima.controller.interceptor;

import com.itheima.controller.system.exception.results.Results;
import com.itheima.controller.system.exception.BusinessException;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Component
@ControllerAdvice
public class ProjectExceptionAdivce {
    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Results doBusinessException(BusinessException ex){
        return new Results(ex.getCode(),ex.getMessage());
    }
}
